﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Silverlight.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Windows.Data;
using ONa.Silverlight.UIComponents.UnitTests.SimpleHtmlFrame.Interfaces;
using ONa.Silverlight.UIComponents.UnitTests.AdvancedHtmlFrame.Interfaces;
using ONa.Silverlight.UIComponents.UnitTests.SimpleHtmlFrame.Views;
using ONa.Silverlight.UIComponents.UnitTests.SimpleHtmlFrame.ViewModels;
using ONa.Silverlight.UIComponents.UnitTests.AdvancedHtmlFrame.Views;
using ONa.Silverlight.UIComponents.UnitTests.AdvancedHtmlFrame.ViewModels;
using ONa.Silverlight.UIComponents.UnitTests.ChildWindowHtmlFrame.Interfaces;
using ONa.Silverlight.UIComponents.UnitTests.ChildWindowHtmlFrame.Views;
using ONa.Silverlight.UIComponents.UnitTests.ChildWindowHtmlFrame.ViewModels;

namespace ONa.Silverlight.UIComponents.UnitTests.HtmlFrame
{
    /// <summary>
    /// Cette classe contient l'ensemble des tests unitaires pour la vue HtmlFrame
    /// </summary>
    [TestClass]
    public class HtmlFrameUnitTestsUI : SilverlightTest
    {
        #region Private Members

        /// <summary>
        /// View Model servant aux tests unitaires
        /// </summary>
        private ISimpleHtmlFrameViewModel simpleHtmlFrameViewModel;

        /// <summary>
        /// View Model servant aux tests unitaires
        /// </summary>
        private IAdvancedHtmlFrameViewModel advancedHtmlFrameViewModel;

        /// <summary>
        /// View Model servant aux tests unitaires
        /// </summary>
        private IChildWindowHtmlFrameViewModel childWindowHtmlFrameViewModel;

        #endregion

        #region Setup Method

        /// <summary>
        /// Cette méthode initialise le Container IoC et instancie le ViewModel
        /// </summary>
        [TestInitialize]
        public void Setup()
        {
            var simpleView = new SimpleHtmlFrameView();
            this.simpleHtmlFrameViewModel = new SimpleHtmlFrameViewModel(simpleView);

            var advancedView = new AdvancedHtmlFrameView();
            this.advancedHtmlFrameViewModel = new AdvancedHtmlFrameViewModel(advancedView);

            var childWindowHtmlFrameView = new ChildWindowHtmlFrameView();
            this.childWindowHtmlFrameViewModel = new ChildWindowHtmlFrameViewModel(childWindowHtmlFrameView);
        }

        #endregion

        #region TestFinalize Method

        /// <summary>
        /// Cette méthode Finilise les Tests Unitaires de cette classe
        /// </summary>
        [TestCleanup]
        public void TestFinalize()
        {
            // UnSubscribe Events, ...
        }

        #endregion

        #region TestMethods

        /// <summary>
        /// Cette méthode permet de vérifier l'affichage d'une Frame HTML simple
        /// </summary>
        [TestMethod]
        [Asynchronous]
        public void UnitTest1_ShowSimpleHtmlFrameView()
        {
            //this.TestPanel.Children.Add(this.simpleHtmlFrameViewModel.View as UIElement);
            EnqueueTestComplete();
        }

        /// <summary>
        /// Cette méthode permet de vérifier l'affichage d'une Frame HTML dans un TabControl
        /// et de vérifier le fonctionnement du Binding sur la Visility du control
        /// </summary>
        [TestMethod]
        [Asynchronous]
        public void UnitTest2_ShowAdvancedHtmlFrameView()
        {
            //this.TestPanel.Children.Add(this.advancedHtmlFrameViewModel.View as UIElement);
            EnqueueTestComplete();
        }

        /// <summary>
        /// Cette méthode permet de vérifier l'affichage d'une Frame HTML dans une ChildWindow
        /// </summary>
        [TestMethod]
        [Asynchronous]
        public void UnitTest3_ShowChildWindowHtmlFrameView()
        {
            this.childWindowHtmlFrameViewModel.View.Show();

            //var childWindowHtmlFrameView2 = new ChildWindowHtmlFrameView();
            //var childWindowHtmlFrameViewModel2 = new ChildWindowHtmlFrameViewModel(childWindowHtmlFrameView2);
            //childWindowHtmlFrameViewModel2.View.Show();
            EnqueueTestComplete();
        }

        #endregion
    }
}
